/**
 * a very useful Toast component which is cross-platform
 */
import React from 'react';

import {
  RootSiblings,
} from '../../index';

import ToastContainer from './ToastContainer';

const POSITIONS = {
  TOP: 'top',
  CENTER: 'center',
  BOTTOM: 'bottom',
};

const DURATIONS = {
  LONG: 3500,
  SHORT: 2000,
  ALWAYS: 'always',
};

class Toast {
  static positions = POSITIONS;

  static durations = DURATIONS;

  static show = (message, options = {}) => {
    return new RootSiblings(
      <ToastContainer
        message={message}
        position={POSITIONS.CENTER}
        duration={DURATIONS.SHORT}
        // wrapperStyle={{}}
        // textStyls={{}}
        // icon={}
        {...options}
      />,
    );
  };

  static hide = (toast, callback) => {
    if (toast instanceof RootSiblings) {
      toast.destroy(callback);
    } else {
      console.error(`Toast.hide expected a \`RootSiblings\` instance as argument.\nBut got \`${typeof toast}\` instead.`);
    }
  };
}

export default Toast;
